<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script>
		class Color {
			constructor(name) {
				this.name = name
			}
		}
		class Shape {
			constructor(name, color) {
				this.name = name
				this.color = color
			}
			draw() {
				console.log(`${this.color.name} ${this.name}`)
			}
		}
		//测试代码
		let red = new Color('red')
		let yellow = new Color('yello')
		let circle = new Shape('circle', red)
		circle.draw()//red circle
		let triangle = new Shape('triangle', yellow)
		triangle.draw()//yello triangle
	</script>
</html>